// pages/user/index.js
const {
  get,
  base
} = getApp();
Page({
  // 数据
  data: {
    data: {},
    showImg: false,
    imgUrl:''
  },
  //跳转下单
  goToOrder: function (e) {
    wx.navigateTo({
      url: `../order/index?active=${e.currentTarget.dataset.id}`,
    })
  },
  // 初始话
  onShow: function () {
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 3
      })
    };
    // 获取数据
    get("/mine/center").then(res => {
      if (res.result == 1) {
        this.setData({
          data: res.data
        })
      }
    });
    // 控制分享按钮
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline'],
      success(res) {
        console.log('showShareMenu', res);
      }
    })
  },
  // 跳转页面
  goToPage: function (e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },
  // 页面跳转
  goToLogin() {
    // if (this.data.data.isEmployee == 1) {
    //   wx.navigateTo({
    //     url: "../assistant/index"
    //   })
    // } else {
      wx.navigateTo({
        url: "../authenticationName/index"
      })
    // }
  },
  // fakai二维码
  openImg() {
    this.setData({
      imgUrl: `${base}qrcode/create?text=${this.data.data.member_code}&w=230&h=230`,
      showImg: true
    })
  },
  // 关闭二维码
  closeImg() {
    this.setData({
      showImg: false
    })
  }
})